#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //启动定时器,它会返回一个timerId
    LCDNumberTimerId = this->startTimer(1000);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::timerEvent(QTimerEvent *event)
{
    if(event->timerId() == LCDNumberTimerId){
        int value = ui->lcdNumber->value();
        if(value <= 0){
            this->killTimer(LCDNumberTimerId);
            return;
        }

        value--;
        ui->lcdNumber->display(value);
    }
}

